Bases: ModelOperationalMetric
Embedding counter metric base; subclass to add one, don't compile it.
Subclasses set _phase to one of "inference", "reward", or
"optimizer" to read the corresponding counter set on each bound
embedding model. Counters are populated by the EM based on the active
op_scope (contextvar) the trainer sets for each phase.
Binds itself automatically to every EmbeddingModel reachable from
the program (and their .fallback chains) on program.compile().
Example (with a concrete subclass):
program.compile(
metrics=[
synalinks.metrics.EmbeddingTokens(),
],
)
Source code in synalinks/src/metrics/em_metrics.py
| @synalinks_export(
[
"synalinks.metrics.EmbeddingModelOperationalMetric",
"synalinks.EmbeddingModelOperationalMetric",
]
)
class EmbeddingModelOperationalMetric(ModelOperationalMetric):
"""Embedding counter metric base; subclass to add one, don't compile it.
Subclasses set `_phase` to one of ``"inference"``, ``"reward"``, or
``"optimizer"`` to read the corresponding counter set on each bound
embedding model. Counters are populated by the EM based on the active
``op_scope`` (contextvar) the trainer sets for each phase.
Binds itself automatically to every `EmbeddingModel` reachable from
the program (and their `.fallback` chains) on `program.compile()`.
Example (with a concrete subclass):
```python
program.compile(
metrics=[
synalinks.metrics.EmbeddingTokens(),
],
)
```
"""
_collect = staticmethod(embedding_models)
_tracked_suffixes = _TRACKED_SUFFIXES
@property
def embedding_models(self):
return list(self._models)
|